/************************************************
*
*   filename:   enemy.cpp
*   date:       11/15/09
*
*   Created by
*       Jason Stafford
*
*   purpose:
*       contains the enemie class
*
*   Revisions:
*       - 11/15/09
*            Created initial methods
*
*   copyright 2009 by
*       Cy Cook
*       Kassandra Kaplan
*       Blaise Millegan
*       Jason Stafford
*
************************************************/
#include <iostream>
#include "enemy.h"
#include <ctime>
#include <cstdlib>
using namespace std;


enemy::enemy(int et, int starting_health)
{
    my_health=starting_health;
    enemy_type = et;
    isAlive = true;
    focus = false;

    chose_heal = false;
    chose_attack = false;
    selected_player = 0;
}

int enemy::update()

{
    //temp varialbes, these will be calls to player later
    int num_players = 4;
    bool players_alive[num_players];
    int players_health[num_players];

    for(int i=0;i<num_players;i++)
    {
        players_alive[i]=true ;
    }
    for(int i=0;i<num_players;i++)
    {
        players_health[i]=100 ;
    }

    for(int i=0;i<num_players;i++)
    {
        if (players_alive[i])
            cout << "Player " << i << " is alive.\n";
    }
    for(int i=0;i<num_players;i++)
    {
        int health = players_health[i];
        cout << "Player " << i << "'s health is " << health << endl;
    }


    int num_playersalive=0;
    int total_health=0;
    int average_health=0;

    for (int i=0;i<num_players;i++)
    {
        if (players_alive[i])
            num_playersalive++;

        total_health+=players_health[i];
    }
    //Calculate average health;
    average_health = total_health/num_playersalive;

    cout << "Total players alive " << num_playersalive << endl;
    cout << "Total health of all players " << total_health << endl;
    cout << "Average Health " << average_health << endl;

    //Attack if weakest character is less has less than 15 health.

    //Start of logic section
    if(my_health > 15)
    {
        //find weakest and strongest player


        //if weakest is less than 15 attack weakest
        //else attack stongest unless there is certain random # thrown


    }
    else
    {
        //My health is below 15 so heal no matter what.
        chose_heal = true;
    }

    if (enemy_type ==1)
    {
    srand( (unsigned)time( NULL ) );
	//int randomNum = rand() % 100;
	for(int i=0; i<2;i++)
	{
	    int randomNum = rand() % 100;
		cout << randomNum << endl;
	}
    }

    return 0;

}


bool enemy::alive()
{
     return isAlive;
}

//SDL Draw function
void enemy::draw(SDL_Surface *screen)
{

}

void enemy::setFocus(bool isFocus)
{
     focus=isFocus;
}

bool enemy::getFocus()
{
    return focus;
}
